﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="System_Data.aspx.cs" Inherits="FPC.Offer.UI.SystemManage.WebForm3" %>

<!DOCTYPE html>


<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link href="../H-ui/static/h-ui/css/H-ui.min.css" rel="stylesheet" />
    <link href="../H-ui/static/h-ui.admin/css/H-ui.admin.css" rel="stylesheet" />
    <link href="../H-ui/Lib/Hui-iconfont/1.0.8/iconfont.css" rel="stylesheet" />
    <link href="../H-ui/static/h-ui.admin/skin/default/skin.css" rel="stylesheet" />
    <link href="../H-ui/static/h-ui.admin/css/style.css" rel="stylesheet" />
    <title>数据字典</title>
</head>
<body>
    <nav class="breadcrumb">
        <i class="Hui-iconfont">&#xe67f;</i> 首页
        <span class="c-gray en">&gt;</span>
        系统管理
        <span class="c-gray en">&gt;</span>
        数据字典
        <a class="btn btn-success radius r" style="line-height: 1.6em; margin-top: 3px" href="javascript:location.replace(location.href);" title="刷新"><i class="Hui-iconfont">&#xe68f;</i></a>
    </nav>
    <div class="page-container">
        <div class="text-c">
            字典名称:
            <input type="text" class="input-text" id="DictionaryName" name="DictionaryName" style="width: 150px">
             字典内容:
            <input type="text" class="input-text" id="PlaceValue" name="PlaceValue" style="width: 150px">
            表名:
            <span class="select-box inline">
                <select class="select" id="PlaceTable" name="PlaceTable" onchange="DropChange()">
                    <option value="0">选择一个系统表名</option>
                </select>
            </span>
            字段名:
            <span class="select-box inline">
                <select class="select" id="PlaceField" name="PlaceField">
                      <option value="0">选择一个系统列名</option>    
                </select>
            </span>

            <button type="submit" class="btn btn-primary radius" id="" name="" onclick="DictionaryAdd()"><i class="Hui-iconfont">&#xe600;</i> 添加字典</button>
        </div>
        <div class="cl pd-5 bg-1 bk-gray mt-20">
            <span class="l">
                <a href="javascript:;" onclick="datadel()" class="btn btn-danger radius"><i class="Hui-iconfont">&#xe6e2;</i> 批量删除</a>
            </span>
            <span class="r" id="GetCount">共有数据：<strong></strong> 条</span>
        </div>
        <div class="mt-20">
            <table class="table table-border table-bordered table-bg table-hover table-sort" id="Ststem_DataTable">
                <thead>
                    <tr class="text-c">
                        <th width="80"><input type="checkbox" name="" value=""></th>
                        <th>名称</th>
                        <th>表名</th>
                        <th>列名</th>
                    </tr>
                </thead>
                <tbody>
                </tbody>
            </table>
        </div>
    </div>
    <!--_footer 作为公共模版分离出去-->
    <script src="../H-ui/Lib/jquery/1.9.1/jquery.min.js"></script>
    <script src="../H-ui/Lib/layer/2.4/layer.js"></script>
    <script src="../H-ui/static/h-ui/js/H-ui.min.js"></script>
    <script src="../H-ui/static/h-ui.admin/js/H-ui.admin.js"></script>
    <!--/_footer 作为公共模版分离出去-->
    <!--请在下方写此页面业务相关的脚本-->
    <script src="../H-ui/Lib/My97DatePicker/4.8/WdatePicker.js"></script>
    <script src="../H-ui/Lib/datatables/1.10.0/jquery.dataTables.min.js"></script>
    <script src="../H-ui/Lib/laypage/1.2/laypage.js"></script>
    <script type="text/javascript">    
        // 页面初次加载
        $(document).ready(function () {
        System_data_show();
            DropShow();
        })
        //下拉菜单
        function DropShow() {

            var s = "FPC_Offer";
            $.ajax({
                tyoe: 'post',
                url: '/GeneralProcessor/Systems/HandlerDictionary.ashx',
                data: {
                    Actioon: '<%=FPC.Offer.Common.EnumAction.Select.ToString() %>',
                    GetName: s,
                },
                success: function (s) {
                    var arr = JSON.parse(s);
                    var tr = new Array();
                    for (var i = 0; i < arr.length; i++) {
                        tr.push("<option value=\"" + arr[i] + "\">" + arr[i] + "</option>");
                    }
                    $("#PlaceTable").append(tr.join());
                }
            });
        };
        //下拉框联动
        function DropChange() {
            $("#PlaceField").empty();
            $.ajax({
                type: 'post',
                url: '/GeneralProcessor/Systems/HandlerDictionary.ashx',
                data: {
                    Actioon: '<%=FPC.Offer.Common.EnumAction.Select.ToString() %>',
                    GetName: $("#PlaceTable").val(),
                },
                success: function (s) {
                    var arr = JSON.parse(s);
                    var tr = new Array();
                    tr.push("<option value=\"0\">选择一个系统列名</option>");
                    for (var i = 0; i < arr.length; i++) {
                        tr.push("<option value=\"" + i + "\">" + arr[i] + "</option>");
                    }
                    $("#PlaceField").empty();
                    $("#PlaceField").append(tr.join());
                }
            })
        };
       
        //数据字典—显示
        function System_data_show() {
            $.ajax({
                type: 'post',
                url: '/GeneralProcessor/Systems/HandlerDictionary.ashx',
                data:{
                    Actioon:'<%=FPC.Offer.Common.EnumAction.Select.ToString() %>',
                    context:'Sysyem_Data',
                },
                success: function (s) {                  
                    var arr =JSON.parse(s);
                    var tr = new Array();
                    $(arr).each(function (i, obj) {
                        tr.push("  <tr class=\"text-c\">");
                        tr.push(" <td><input type=\"checkbox\" value=\"\" name=\"\"></td> ");
                        //tr.push("    <td>" + obj.PlaceId + "</td>");
                        tr.push("    <td><a href=\"Data_Show.aspx?PlaceField=" + obj.PlaceField + " \">" + obj.DictionaryName + "</a></td> ");
                        if(obj.PlaceTable=="null"){
                            tr.push("  <td>无</td>  ");
                        }
                        else
                        {
                            tr.push("  <td>" + obj.PlaceTable + "</td>  ");
                        }                     
                        tr.push("    <td>" + obj.PlaceField + "</td> ");
                        //tr.push("<td class=\"f-14\"><a style=\"text-decoration:none\" onclick=\"system_data_edit('角色编辑','system-data-edit.html','0001','400','310')\" href=\"javascript:;\" title=\"编辑\"><i class=\"Hui-iconfont\">&#xe6df;</i></a>   <a title=\"删除\" href=\"javascript:;\" onclick=\"system_data_del(this,'10001')\" class=\"ml-5\" style=\"text-decoration:none\"><i class=\"Hui-iconfont\">&#xe6e2;</i></a> </td>");
                        tr.push(" </tr>");                
                    })
                   
                    $("#Ststem_DataTable").append(tr.join());
                }
            })
        };
        //添加数据字典
        function DictionaryAdd() {
            if ($("#DictionaryName").val() == "") {
                alert("请添加字典名称！"); return;
            }
            if ($("#PlaceTable").val() == "0") {
                alert("请选择系统表名！"); return;
            }
            if ($("#PlaceField").val() == "0") {
                alert("请选择列名！"); return;
            }
            if ($("#PlaceValue").val() == "0") {
                alert("请选择列名！"); return;
            }
            
            $.ajax({
                type: 'post',
                url: '/GeneralProcessor/Systems/HandlerDictionary.ashx',
                data: {
                    Actioon: '<%=FPC.Offer.Common.EnumAction.Add.ToString() %>',
                    DictionaryName: $("#DictionaryName").val(),
                    PlaceTable: $("#PlaceTable").val(),
                    PlaceField: $("#PlaceField").val(),
                    PlaceValue: $("#PlaceValue").val(),
                },
                success: function (s) {
                    if (parseInt(s) > 0) {
                        alert("添加成功"); location.reload();
                    }
                    else {
                        alert("添加失败，请重新添加");
                    }
                }
            })
        }
    </script>
</body>
</html>